{template 'common/header'}

<div class="clearfix">
<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('goods')}">商品列表</a></li>
	<li><a href="{php echo $this->createWebUrl('addgoods')}">添加商品</a></li>
	<li><a href="{php echo $this->createWebUrl('indexsort')}">首页商品分类</a></li>
	<li><a href="{php echo $this->createWebUrl('indexsort_post')}">添加首页商品分类</a></li>
	<li><a href="{php echo $this->createWebUrl('sort')}">商品分类</a></li>
	<li><a href="{php echo $this->createWebUrl('sort_post')}">添加商品分类</a></li>
</ul>
<div class="panel panel-default">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="" method="post" class="form-horizontal" role="form" id="form">
			<div class="form-group">
				<label class="col-md-2 control-label">商品名</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="keyword" id="keyword" value="{$keyword}">
				</div>
				<div class="pull-right col-md-2">
					<button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="main panel panel-default">
	<div class="table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:5%;" class="text-center">id</th>
					<th style="width:20%;" class="text-center">商品名</th>
					<th style="width:20%;" class="text-center">商品图</th>
					<th style="width:10%;" class="text-center">价格</th>
					<th style="width:10%;" class="text-center">库存</th>
					<th style="width:10%;" class="text-center">排序</th>
					<th style="width:10%;" class="text-center">状态</th>
					<th class="text-right" style="width:15%;" class="text-center">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $index $item}
				<tr>
					<td class="text-center">{$item['id']}</td>
					<td class="text-center">{$item['goods_name']}</td>
					<td class="text-center"><img class="scrollLoading" src="{media $item['main_img']}" data-url="{media $item['main_img']}"  height="50" width="50"></td>
					<td class="text-center">
                        {if $item['paytype'] == 1}
							{$item['rmb']} + {$item['price2']}
							{else}
							{$item['price']}
						{/if}
					</td>
					<td class="text-center">{$item['inventory']}</td>
					<td><input type="text" class="form-control displayorder" data-id="{$item['id']}" name="displayorder" value="{$item['displayorder']}"></td>
					<td class="text-center">
					    {if $item['status'] == 1}
							<span class="label label-success">上架</span>
							{else}
							<span class="label label-default">下架</span>
						{/if}
					</td>
					<td class="text-right">
						<a href="{php echo $this->createWebUrl('addgoods',array('id'=>$item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('addgoods',array('act'=>'del','id'=>$item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
				{if empty($list) }
                <tr ng-if="!wechats">
                <td colspan="9" class="text-center">暂无数据</td>
                </tr>
                {/if}

                <tr>
					<td colspan="9" style="text-align:right">{$page}</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
<script type="text/javascript">
$(".displayorder").bind('input propertychange',function(){
	$.ajax({
	    url:"{php echo $this->createWebUrl('addgoods',array('act'=>'display'))}",
	    type:'POST',
	    async:true,
	    data:{
	        displayorder:$(this).val(),id:$(this).attr('data-id')
	    },
	    timeout:5000,
	    dataType:'json',
	    success:function(data){
	        //alert(data.message);
	    }
	})
})
</script>
</div>

{template 'common/footer'}